package day07;


import java.util.Random;

/**
 * @author Huangjin
 * @version 1.0
 * describe:验证码
 *  生成4位的验证码（大写字母，小写字母，数字）
 * @date 2023/2/20 16:09
 */
public class VerificationCode {
    public static void main(String[] args) {
        String code = generateVeriCode(4);
        System.out.println("车牌号："+ code);
    }

    public static String generateVeriCode(int len){
        String code = "";
        String code1 = "";
        String code2 ="";
        String p ="•";
        char[] ch = {'贵','川','云','赣','京','粤'};
        char[] chss = {'A','B','C','D','E','F',
                'G','H','J'};
        char[] chs = {'A','B','C','D','E','F',
                'G','H','I','J','K','L','M','N','O','P','Q','R',
                'S','T','U','V','W','X','Y','Z','0','1','2','3',
                '4','5','6','7','8','9'};
        for (int i = 0; i <=len ; i++) {
            //随机下标
            //int index = (int)(Math.random()*chs.length);
            Random random = new Random();
            int index = random.nextInt(chs.length);
            //获取随机字符凭借到code中
            code += chs[index];


        }
        for (int i = 0; i < 1; i++) {
            Random random = new Random();
            int index1 = random.nextInt(ch.length);
            code1 += ch[index1];
        }
        for (int i = 0; i < 1; i++) {
            Random random = new Random();
            int index1 = random.nextInt(ch.length);
            code1 += chss[index1];
        }
        String a = code1+code2+p+code;
        return a;
    }
}
/*
'a','b','c','d','e','f','g','h',
                'i','j','k','l','m','n','o','p','q','r','s','t',
                'u','v','w','x','y','z',
 */